package com.ssm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ssm.domain.User;
import com.ssm.service.TestService;
import com.ssm.service.UserService;

@Controller
public class MainController {
	
	@Autowired
	TestService testService;
	
	@Autowired
	UserService userService;
	
	@RequestMapping(value = "/", method = RequestMethod.GET)
    public String index(){
        return "index";
    }
	@RequestMapping(value = "test", method = RequestMethod.GET)
    public String test(){
        return "test";
    }
	
	@RequestMapping(value = "springtest", method = RequestMethod.GET)
    public String springTest(){
        return testService.test();
    }
	
	@RequestMapping(value = "mybatis")
	@ResponseBody
    public String mybatis(){
		User user = new User();
		user.setUsername("test2");
		user.setPassword("123");
		user.setAddress("sasasas");
		userService.insert(user);
        return "success";
    }
}
